<?php

namespace App\Models;


use Illuminate\Database\Eloquent\Relations\BelongsTo;

class DocumentOrder extends BaseModel
{
    protected $guarded = [];

    protected $table = 'qh_document_orders';

    protected $appends = ['statusText'];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class, 'userId');
    }

    public function document(): BelongsTo
    {
        return $this->belongsTo(Document::class, 'documentId');
    }

    public function getStatusTextAttribute(): string
    {
        if (empty($this->getAttributes()['status'])) return "";
        return !empty(ORDER_STATUS[$this->getAttributes()['status']]) ? ORDER_STATUS[$this->getAttributes()['status']] : '未知状态';
    }
}
